<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('春藤')"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">春藤医疗管理系统</div>
        <ul class="layui-nav layui-layout-left">

        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" class="layui-nav-img">
                    <span th:text="${user.userName}"></span>
                </a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/sysuser/info}" target="ctIframe">个人信息</a></dd>
                    <dd><a th:href="@{/logout}">退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-this"><a th:href="@{main}" target="ctIframe">首页</a></li>
                <li class="layui-nav-item" th:each="menus : ${user.sysMenusList}" th:if="${menus.menuType == 1}">
                    <a th:href="${#strings.isEmpty(menus.menuUrl) ? 'javascript:;' : menus.menuUrl}" th:text="${menus.menuName}" target="ctIframe"></a>
                    <dl class="layui-nav-child">
                        <dd th:each="menusC : ${user.sysMenusList}" th:if="${menusC.parentId == menus.id && menusC.menuType == 2}">
                            <a th:href="${#strings.isEmpty(menusC.menuUrl) ? 'javascript:;' : menusC.menuUrl}" th:text="${menusC.menuName}" target="ctIframe"></a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body" style="padding: 15px;">
        <iframe src="/main" name="ctIframe" id="ctIframe" frameborder="0" width="100%" height="100%" scrolling="auto" onload="changeIFrameSrc(this)"></iframe>
    </div>

    <div class="layui-footer">
        春藤医疗管理系统 Version:1.0
    </div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    layui.use(['element', 'layer', 'util'], function () {

    });

    function changeIFrameSrc(obj) {
        var url = obj.contentWindow.location.href;
        let login = url.substring(url.lastIndexOf("/"), url.length);
        if (login == "/login") {
            window.location.href = "/login?msg=登录信息过期,请重新登录!";
        }
    }


    $(function () {
        $(".main_left li").on("click", function () {
            var address = $(this).attr("data-src");
            $("iframe").attr("src", address);
        });
    });
</script>
</body>
</html>